#include <iostream>
#include <string>
using namespace std;

class Solution {
public:
    string addStrings(string num1, string num2)
    {
        string result;
        int next = 0;

        char tmp1 = 0;
        char tmp2 = 0;

        while (!num1.empty() || !num2.empty())
        {
            if (!num1.empty())
                tmp1 = num1[num1.size() - 1] - 48;
            else
                tmp1 = 0;

            if (!num2.empty())
                tmp2 = num2[num2.size() - 1] - 48;
            else
                tmp2 = 0;

            int sum = tmp1 + tmp2 + next;
            next = sum / 10;
            sum %= 10;

            result += (sum + 48);

            if (!num1.empty())
                num1.erase(num1.end() - 1);
            if (!num2.empty())
                num2.erase(num2.end() - 1);
        }

        if (next > 0)
            result += '1';

        reverse(result.begin(), result.end());
        return result;
    }
};